package com.itheima.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

	@Autowired(required = false)
	private List<HandlerInterceptor> myInterceptors;

	public void addInterceptors(InterceptorRegistry registry) {
		if (myInterceptors != null) {
			myInterceptors.forEach(interceptor -> {
				registry.addInterceptor(interceptor).addPathPatterns(new String[] { "/**" });
			});
		}
	}

}
